package com.ml.mall.utils;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ml.mall.bean.req.vo.OrderMailTemplateVO;
import com.ml.mall.bean.res.order.OrderQueryOneRes;
import com.ml.mall.bean.vo.coupon.CupponDetailVO;
import com.ml.mall.entity.coupon.SysCouponRecord;
import com.ml.mall.entity.detail.SysOrderDetail;
import com.ml.mall.entity.msg.SysOrderMsg;
import com.ml.mall.entity.supplier.SysOrderSupplier;
import com.ml.mall.entity.sys.SysUser;
import com.ml.mall.enums.RetStatusNum;
import com.ml.mall.exception.BizException;
import com.ml.mall.security.JwtUtil;
import com.ml.mall.service.coupon.SysCouponRecordService;
import com.ml.mall.service.coupon.SysCouponService;
import com.sun.corba.se.spi.resolver.Resolver;
import org.springframework.beans.factory.annotation.Autowired;

import javax.naming.NamingEnumeration;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author :pl
 * @version :1.0
 * @description :邮箱模板
 * @date :2021/8/12
 **/
public class MailTemplateUtils {
    //买家订单发送的邮件信息
    public static StringBuilder MailTeplate(OrderMailTemplateVO orderMailTemplateVO,SysUser sysUser,SysOrderMsg sysOrderMsg){
        StringBuilder sb=new StringBuilder();
        if(null != orderMailTemplateVO){
            SysUser currentUser=null;
            if(sysUser != null){
                currentUser =sysUser;
            }
            if (null==currentUser){
                throw new BizException(RetStatusNum.ACC_NO.getCode(),RetStatusNum.ACC_NO.getMessage());
            }

            //顶部信息
            StringBuilder top=new StringBuilder("<div><br></div><div><includetail><div style='width: 1000px; margin: auto; text-align: left;font-family: 'Helvetica', sans-serif;'>" +
                    "" +
                    "<img src=mainPicUrl style='width: 100%; height: 200px; margin: -8px;'>" +
                    "" +
                    "<div style='border-bottom: solid 0.5px #e1e6ed; padding-bottom: 50px; width: 90%; margin: auto;'>" +
                    "" +
                    "<div style='width: 70%;'>" +
                    "" +
                    "<span style='font-weight: bold; font-size: 32pt; color: #06375b;'>\n" +
                    "\n" +
                    "Purchase order payment <span style=\"color: #54af9a;\">done</span>!\n" +
                    "\n" +
                    "</span>\n" +
                    "\n" +
                    "</div>\n" +
                    "\n" +
                    "</div>\n" +
                    "\n" +
                    "<div style=\"width: 90%; margin: auto; padding-top: 20px;\">\n" +
                    "\n" +
                    "<p>Hi <strong> USERNAME ,</strong></p>\n" +
                    "\n" +
                    "<br>\n" +
                    "\n" +
                    "<p>You have made a payment of <strong> "+orderMailTemplateVO.getAllQuantity()+" </strong> for purchase order <strong> "+orderMailTemplateVO.getOid()+" </strong> with details as below:</p>");
            sb.append(top);

            //卖家订单
            if(null != orderMailTemplateVO.getOrderArr() && orderMailTemplateVO.getOrderArr().size()>0){
                orderMailTemplateVO.getOrderArr().stream().forEach(it->{
                    StringBuilder h=new StringBuilder("<div style=\"background-color: #EFF2F4\">\n" +
                            "\n" +
                            "<h4>Products</h4>\n" +
                            "\n" +
                            "<div class=\"supplier-products-info\">\n" +
                            "\n" +
                            "<div style=\"display: inline-block; width: 25%;\">\n" +
                            "\n" +
                            "<strong> "+it.getSupplierCompanyName()+" </strong>\n" +
                            "\n" +
                            "</div>\n" +
                            "</div>\n" +
                            "\n" +
                            "<div style=\"display: inline-block;\">\n" +
                            "</div>\n" +
                            "\n" +
                            "<div style=\"display: inline-block;\">\n" +
                            "</div>\n" +
                            "\n" +
                            "</div>\n" +
                            "\n" +
                            "<div class=\"supplier-product-table\" style=\"padding-top: 20px; padding-bottom: 30px; border-bottom: solid 0.5px #D4DAE6;\">\n" +
                            "\n" +
                            "<table style=\"width: 100%; border-radius: 5px; border-collapse: collapse;\">\n" +
                            "\n" +
                            "<tbody><tr><th style=\"width: 15%; padding: 5px 10px;\">Image</th><th style=\"width: 40%;text-align: left;\">Product Name</th><th style=\"width: 10%;text-align: center;\">Quantity</th><th style=\"width: 15%;text-align: right;\">Unit Price</th><th style=\"width: 10%;text-align: right; padding-right: 10px;\">Total</th></tr>");

                    StringBuilder l=new StringBuilder();

                    if(null != it.getOrderDetailArr() && it.getOrderDetailArr().size()>0){
                        it.getOrderDetailArr().stream().forEach(od->{
                            StringBuilder j=new StringBuilder("<tr style=\"background-color: #DCE5F2; border-radius: 10px;\">\n" +
                                    "\n" +
                                    "<td style=\"border: none; padding: 10px 0 10px 10px;\">\n" +
                                    "\n" +
                                    "<img src=http://res.airenaprocure.com/static"+od.getPicUrl()+" style=\"width: 75px; height: 75px;\">\n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "<td style=\"border: none;\">\n" +
                                    "\n" +
                                    " "+od.getVariantName()+" \n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "<td style=\"border: none; text-align: center;\">\n" +
                                    "\n" +
                                    " "+od.getQuantity()+" \n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "<td style=\"border: none; text-align: right;\">\n" +
                                    "\n" +
                                    "<div style=\"padding-bottom: 5px;\">RM  "+od.getPrice()+" </div>\n" +
                                    "\n" +
                                    "<div style=\"padding-bottom: 5px;\">RM  "+od.getSellPrice()+" </div>\n" +
                                    "\n" +
                                    "<div>RM  "+od.getBuyunit()+" </div>\n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "<td style=\"border: none; text-align: right; padding-right: 10px;\">\n" +
                                    "\n" +
                                    "RM  "+od.getAllmoney()+" \n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "</tr>");
                            l.append(j);
                        });
                    }
                    if(null != it.getCupponVOList() && it.getCupponVOList().size()>0){
                        it.getCupponVOList().stream().forEach(itt->{
                            StringBuilder k=new StringBuilder("<tr style=\"border-radius: 10px; font-weight: bold;\">\n" +
                                    "\n" +
                                    "<td colspan=\"4\" style=\"text-align: right;\">\n" +
                                    "\n" +
                                    "<div>Delivery Fee (Delivered by [ logistic_company_name ]) :</div>\n" +
                                    "\n" +
                                    "<div style=\"padding: 5px\">\n" +
                                    "\n" +
                                    "<div style=\"display: inline-block; width: 100px; font-size: 13px; padding-left: 5px; float: right; vertical-align: middle; line-height: 30px;\">\n" +
                                    "\n" +
                                    "("+itt.getSysCoupon().getDescription()+")\n" +
                                    "\n" +
                                    "</div>\n" +
                                    "\n" +
                                    "<div style=\"background-color: #2C84EA; border-radius: 5px; width: 100px; font-size: 13px; padding: 5px; float: right; display: inline-block;\">\n" +
                                    "\n" +
                                    "<span style=\"color: white;\">"+itt.getSysCoupon().getCouponName()+"</span>\n" +
                                    "\n" +
                                    "\n" +
                                    "</div>\n" +
                                    "\n" +
                                    "</div>\n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "<td style=\"text-align: right; font-size: 13px; padding-right: 10px; padding-bottom: 10px;\">\n" +
                                    "\n" +
                                    "<div class=\"delivery_fee\">\n" +
                                    "\n" +
                                    "RM "+it.getDeliveryFee()+"\n" +
                                    "\n" +
                                    "</div>\n" +
                                    "\n" +
                                    "<div>\n" +
                                    "\n" +
                                    "- RM "+itt.getSysCoupon().getCouponMoney()+"\n" +
                                    "\n" +
                                    "</div>\n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "</tr>");
                            l.append(k);
                        });
                    }
                    StringBuilder m=new StringBuilder(
                            "</tbody></table>\n" +
                            "\n" +
                            "</div>\n" +
                            "\n" +
                            "</div>");
                    l.append(m);
                    h.append(l);
                    sb.append(h);
                });

            }


            //尾部上半部分不需要循环的内容
            StringBuilder g=new StringBuilder("<div style=\"background-color: #EFF2F4;padding-bottom: 20px;\">\n" +
                    "\n" +
                    "<table style=\"width: 100%; border-radius: 5px; border-collapse: collapse;\">\n" +
                    "\n" +
                    "<tbody><tr>\n" +
                    "\n" +
                    "<td style=\"width: 45%;text-align: left\">\n" +
                    "\n" +
                    "<div style=\"padding-bottom: 5px\">\n" +
                    "\n" +
                    "<span style=\"font-weight: bold;\">Delivery Note</span>\n" +
                    "\n" +
                    "</div>\n" +
                    "\n" +
                    "<div style=\"padding-bottom: 10px\">\n" +
                    "\n" +
                    "<textarea rows=\"5\" cols=\"60\" readonly=\"\" style=\"border-radius: 5px; resize: none;\">"+(sysOrderMsg.getBuyerMsg()==null?"":sysOrderMsg.getBuyerMsg())+"</textarea>\n" +
                    "\n" +
                    " \n" +
                    "\n" +
                    "</div>\n" +
                    "\n" +
                    "</td>\n" +
                    "\n" +
                    "<th style=\"width: 55%; text-align: right;\">\n" +
                    "\n" +
                    "<table style=\"width: 100%; font-size:13px\">\n" +
                    "\n" +
                    "<tbody><tr>\n" +
                    "\n" +
                    "<td style=\"width: 25%; text-align: left;\">Sub total</td>\n" +
                    "\n" +
                    "<td style=\"width: 5%\">:</td>\n" +
                    "\n" +
                    "<td style=\"width: 45%\"></td>\n" +
                    "\n" +
                    "<td style=\"width: 25%;\">RM "+orderMailTemplateVO.getSubFee()+"</td>\n" +
                    "\n" +
                    "</tr>\n" +
                    "\n" +
                    "");

            sb.append(g);


            //尾部中间需要循环的优惠券
            if(null != orderMailTemplateVO.getCupponVOList() && orderMailTemplateVO.getCupponVOList().size()>0){
                orderMailTemplateVO.getCupponVOList().stream().forEach(it->{
                        StringBuilder o=new StringBuilder("<tr>\n" +
                                "\n" +
                                "<td style=\"width: 25%; text-align: left;\">Coupon</td>\n" +
                                "\n" +
                                "<td style=\"width: 5%\">:</td>\n" +
                                "\n" +
                                "<td style=\"width: 45%\">\n" +
                                "\n" +
                                "<div style=\"padding-bottom: 5px\">\n" +
                                "\n" +
                                "<div style=\"display: inline-block; width: 100px; font-size: 13px; padding-left: 5px; float: right; vertical-align: middle; line-height: 30px;\">\n" +
                                "\n" +
                                "("+it.getSysCoupon().getDescription()+")\n" +
                                "\n" +
                                "</div>\n" +
                                "\n" +
                                "<div style=\"background-color: #F5537F; border-radius: 5px; width: 100px; font-size: 13px; padding: 5px; float: right; display: inline-block;\">\n" +
                                "\n" +
                                "<span style=\"color: white;\">"+it.getSysCoupon().getCouponName()+"</span>\n" +
                                "\n" +
                                "</div>\n" +
                                "\n" +
                                "</div>\n" +
                                "\n" +
                                "</td>\n" +
                                "\n" +
                                "<td style=\"width: 25%;\">- RM "+it.getSysCoupon().getCouponMoney()+"</td>\n" +
                                "\n" +
                                "</tr>");
                        sb.append(o);
                });

            }
            //尾部下部分不需要循环的信息
            StringBuilder p=new StringBuilder("<tr>\n" +
                    "\n" +
                    "<td style=\"width: 25%; text-align: left;\">Delivery Fee</td>\n" +
                    "\n" +
                    "<td style=\"width: 5%\">:</td>\n" +
                    "\n" +
                    "<td style=\"width: 45%\"></td>\n" +
                    "\n" +
                    "<td style=\"width: 25%;\">RM "+orderMailTemplateVO.getDeliveryFee()+"</td>\n" +
                    "\n" +
                    "</tr>\n" +
                    "\n" +
                    "<tr>\n" +
                    "\n" +
                    "<td style=\"width: 25%; text-align: left;\">Adjustment</td>\n" +
                    "\n" +
                    "<td style=\"width: 5%\">:</td>\n" +
                    "\n" +
                    "<td style=\"width: 45%\"></td>\n" +
                    "\n" +
                    "<td style=\"width: 25%;\">RM "+orderMailTemplateVO.getAdaptFee()+"</td>\n" +
                    "\n" +
                    "</tr>\n" +
                    "\n" +
                    "<tr>\n" +
                    "\n" +
                    "<td style=\"width: 25%; text-align: left;\">Credit</td>\n" +
                    "\n" +
                    "<td style=\"width: 5%\">:</td>\n" +
                    "\n" +
                    "<td style=\"width: 45%\"></td>\n" +
                    "\n" +
                    "<td style=\"width: 25%;\">- RM "+orderMailTemplateVO.getSubFee()+"</td>\n" +
                    "\n" +
                    "</tr>\n" +
                    "\n" +
                    "<tr>\n" +
                    "\n" +
                    "<td style=\"width: 25%; text-align: left;\">Total (Incl. Tax)</td>\n" +
                    "\n" +
                    "<td style=\"width: 5%\">:</td>\n" +
                    "\n" +
                    "<td style=\"width: 45%\"></td>\n" +
                    "\n" +
                    "<td style=\"width: 25%;\">RM "+orderMailTemplateVO.getAllQuantity()+"</td>\n" +
                    "\n" +
                    "</tr>\n" +
                    "\n" +
                    " \n" +
                    "\n" +
                    "</tbody></table>\n" +
                    "\n" +
                    "</th>\n" +
                    "\n" +
                    "</tr>\n" +
                    "\n" +
                    "</tbody></table>\n" +
                    "\n" +
                    "</div>\n" +
                    "\n" +
                    "<br>\n" +
                    "\n" +
                    "<a href=SYSTEM_URL style=\"color: #2c84ea; font-weight: bold;\"> system_url </a>\n" +
                    "\n" +
                    "<br>\n" +
                    "\n" +
                    "<p>Need help? Contact <strong>contact_no</strong> or send email to <strong> general_email </strong> for system enquiry.</p>\n" +
                    "\n" +
                    "<br>\n" +
                    "\n" +
                    "<p>Best regards,<br><strong>Airena Procure System</strong></p>\n" +
                    "\n" +
                    "\n" +
                    "</div>");
            sb.append(p);
        }
        String s = sb.toString().replaceAll("\n", "");
        String s1 = s.replaceAll("\"", "'");
        StringBuilder stringBuilder=new StringBuilder(s1);
        return stringBuilder;

    }

    //卖家订单发送的邮件信息
    public static StringBuilder MailSupplierTeplate(SysOrderSupplier sysOrderSupplier, List<SysOrderDetail> sysOrderDetails, List<CupponDetailVO> cupponDetailVOList, SysOrderMsg sysOrderMsg){
        StringBuilder sb=new StringBuilder();
        //顶部信息
        StringBuilder top=new StringBuilder("<div><br></div><div><includetail><div style='width: 1000px; margin: auto; text-align: left;font-family: 'Helvetica', sans-serif;'>" +
                "" +
                "<img src=mainPicUrl style='width: 100%; height: 200px; margin: -8px;'>" +
                "" +
                "<div style='border-bottom: solid 0.5px #e1e6ed; padding-bottom: 50px; width: 90%; margin: auto;'>" +
                "" +
                "<div style='width: 70%;'>" +
                "" +
                "<span style='font-weight: bold; font-size: 32pt; color: #06375b;'>\n" +
                "\n" +
                "Purchase order payment <span style=\"color: #54af9a;\">done</span>!\n" +
                "\n" +
                "</span>\n" +
                "\n" +
                "</div>\n" +
                "\n" +
                "</div>\n" +
                "\n" +
                "<div style=\"width: 90%; margin: auto; padding-top: 20px;\">\n" +
                "\n" +
                "<p>Hi <strong> USERNAME ,</strong></p>\n" +
                "\n" +
                "<br>\n" +
                "\n" +
                "<p>You have made a payment of <strong> AllQuantity </strong> for purchase order <strong> "+sysOrderSupplier.getSupplierOid()+" </strong> with details as below:</p>");

                //卖家订单
                StringBuilder h=new StringBuilder("<div style=\"background-color: #EFF2F4\">\n" +
                        "\n" +
                        "<h4>Products</h4>\n" +
                        "\n" +
                        "<div class=\"supplier-products-info\">\n" +
                        "\n" +
                        "<div style=\"display: inline-block; width: 25%;\">\n" +
                        "\n" +
                        "<strong> "+sysOrderSupplier.getSupplierCode()+" </strong>\n" +
                        "\n" +
                        "</div>\n" +
                        "\n" +
                        "<div style=\"display: inline-block;\">\n" +
                        "</div>\n" +
                        "\n" +
                        "<div style=\"display: inline-block;\">\n" +
                        "</div>\n" +
                        "\n" +
                        "<div style=\"display: inline-block;\">\n" +
                        "</div>\n" +
                        "\n" +
                        "</div>\n" +
                        "\n" +
                        "<div class=\"supplier-product-table\" style=\"padding-top: 20px; padding-bottom: 30px; border-bottom: solid 0.5px #D4DAE6;\">\n" +
                        "\n" +
                        "<table style=\"width: 100%; border-radius: 5px; border-collapse: collapse;\">\n" +
                        "\n" +
                        "<tbody><tr><th style=\"width: 15%; padding: 5px 10px;\">Image</th><th style=\"width: 40%;text-align: left;\">Product Name</th><th style=\"width: 10%;text-align: center;\">Quantity</th><th style=\"width: 15%;text-align: right;\">Unit Price</th><th style=\"width: 10%;text-align: right; padding-right: 10px;\">Total</th></tr>");
                     StringBuilder l=new StringBuilder();
                    Integer AllQuantity=0;
                    if(null != sysOrderDetails && sysOrderDetails.size()>0) {
                        for (SysOrderDetail od : sysOrderDetails) {
                            BigDecimal allMoney=od.getOriginalSellPrice()==null?od.getOriginalPrice().multiply(new BigDecimal(od.getQuantity())):od.getOriginalSellPrice().multiply(new BigDecimal(od.getQuantity()));
                            AllQuantity += od.getQuantity();
                            StringBuilder j = new StringBuilder("<tr style=\"background-color: #DCE5F2; border-radius: 10px;\">\n" +
                                    "\n" +
                                    "<td style=\"border: none; padding: 10px 0 10px 10px;\">\n" +
                                    "\n" +
                                    "<img src=http://res.airenaprocure.com/static"+od.getPicUrl()+" style=\"width: 75px; height: 75px;\">\n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "<td style=\"border: none;\">\n" +
                                    "\n" +
                                    " " + od.getVariantName() + " \n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "<td style=\"border: none; text-align: center;\">\n" +
                                    "\n" +
                                    " " + od.getQuantity() + " \n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "<td style=\"border: none; text-align: right;\">\n" +
                                    "\n" +
                                    "<div style=\"padding-bottom: 5px;\">RM  " + od.getOriginalPrice() + " </div>\n" +
                                    "\n" +
                                    "<div style=\"padding-bottom: 5px;\">RM  " + od.getOriginalSellPrice() + " </div>\n" +
                                    "\n" +
                                    "<div>RM  " + od.getBuyunit() + " </div>\n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "<td style=\"border: none; text-align: right; padding-right: 10px;\">\n" +
                                    "\n" +
                                    "RM  " + allMoney + " \n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "</tr>");
                            l.append(j);
                        };
                        String allQuantity = top.toString().replaceAll("AllQuantity", AllQuantity.toString());
                        top=new StringBuilder(allQuantity);
                    }
                    if(null != cupponDetailVOList && cupponDetailVOList.size()>0){
                        cupponDetailVOList.stream().forEach(itt->{
                            StringBuilder k=new StringBuilder("<tr style=\"border-radius: 10px; font-weight: bold;\">\n" +
                                    "\n" +
                                    "<td colspan=\"4\" style=\"text-align: right;\">\n" +
                                    "\n" +
                                    "<div>Delivery Fee (Delivered by [ logistic_company_name ]) :</div>\n" +
                                    "\n" +
                                    "<div style=\"padding: 5px\">\n" +
                                    "\n" +
                                    "<div style=\"display: inline-block; width: 100px; font-size: 13px; padding-left: 5px; float: right; vertical-align: middle; line-height: 30px;\">\n" +
                                    "\n" +
                                    "("+itt.getSysCoupon().getDescription()+")\n" +
                                    "\n" +
                                    "</div>\n" +
                                    "\n" +
                                    "<div style=\"background-color: #2C84EA; border-radius: 5px; width: 100px; font-size: 13px; padding: 5px; float: right; display: inline-block;\">\n" +
                                    "\n" +
                                    "<span style=\"color: white;\">"+itt.getSysCoupon().getCouponName()+"</span>\n" +
                                    "\n" +
                                    "\n" +
                                    "</div>\n" +
                                    "\n" +
                                    "</div>\n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "<td style=\"text-align: right; font-size: 13px; padding-right: 10px; padding-bottom: 10px;\">\n" +
                                    "\n" +
                                    "<div class=\"delivery_fee\">\n" +
                                    "\n" +
                                    "RM [111]\n" +
                                    "\n" +
                                    "</div>\n" +
                                    "\n" +
                                    "<div>\n" +
                                    "\n" +
                                    "- RM "+itt.getSysCoupon().getCouponMoney()+"\n" +
                                    "\n" +
                                    "</div>\n" +
                                    "\n" +
                                    "</td>\n" +
                                    "\n" +
                                    "</tr>");
                            l.append(k);
                        });
                    }
                StringBuilder m=new StringBuilder(
                        "</tbody></table>\n" +
                                "\n" +
                                "</div>\n" +
                                "\n" +
                                "</div>");


        //尾部上半部分不需要循环的内容
        StringBuilder g=new StringBuilder("<div style=\"background-color: #EFF2F4;padding-bottom: 20px;\">\n" +
                "\n" +
                "<table style=\"width: 100%; border-radius: 5px; border-collapse: collapse;\">\n" +
                "\n" +
                "<tbody><tr>\n" +
                "\n" +
                "<td style=\"width: 45%;text-align: left\">\n" +
                "\n" +
                "<div style=\"padding-bottom: 5px\">\n" +
                "\n" +
                "<span style=\"font-weight: bold;\">Delivery Note</span>\n" +
                "\n" +
                "</div>\n" +
                "\n" +
                "<div style=\"padding-bottom: 10px\">\n" +
                "\n" +
                "<textarea rows=\"5\" cols=\"60\" readonly=\"\" style=\"border-radius: 5px; resize: none;\">" +(sysOrderMsg.getBuyerMsg()==null?" ":sysOrderMsg.getBuyerMsg())+ "</textarea>\n" +
                "\n" +
                " \n" +
                "\n" +
                "</div>\n" +
                "\n" +
                "</td>\n" +
                "\n" +
                "<th style=\"width: 55%; text-align: right;\">\n" +
                "\n" +
                "<table style=\"width: 100%; font-size:13px\">\n" +
                "\n" +
                "<tbody><tr>\n" +
                "\n" +
                "<td style=\"width: 25%; text-align: left;\">Sub total</td>\n" +
                "\n" +
                "<td style=\"width: 5%\">:</td>\n" +
                "\n" +
                "<td style=\"width: 45%\"></td>\n" +
                "\n" +
                "<td style=\"width: 25%;\">RM "+sysOrderSupplier.getSubOriFee()+"</td>\n" +
                "\n" +
                "</tr>\n" +
                "\n" +
                "");

        //尾部下部分不需要循环的信息
        StringBuilder p=new StringBuilder("<tr>\n" +
                "\n" +
                "<td style=\"width: 25%; text-align: left;\">Delivery Fee</td>\n" +
                "\n" +
                "<td style=\"width: 5%\">:</td>\n" +
                "\n" +
                "<td style=\"width: 45%\"></td>\n" +
                "\n" +
                "<td style=\"width: 25%;\">RM "+sysOrderSupplier.getDeliveryFee()+"</td>\n" +
                "\n" +
                "</tr>\n" +
                "\n" +
                "<tr>\n" +
                "\n" +
                "<td style=\"width: 25%; text-align: left;\">Total (Incl. Tax)</td>\n" +
                "\n" +
                "<td style=\"width: 5%\">:</td>\n" +
                "\n" +
                "<td style=\"width: 45%\"></td>\n" +
                "\n" +
                "<td style=\"width: 25%;\">RM "+sysOrderSupplier.getSubOriFee()+"</td>\n" +
                "\n" +
                "</tr>\n" +
                "\n" +
                " \n" +
                "\n" +
                "</tbody></table>\n" +
                "\n" +
                "</th>\n" +
                "\n" +
                "</tr>\n" +
                "\n" +
                "</tbody></table>\n" +
                "\n" +
                "</div>\n" +
                "\n" +
                "<br>\n" +
                "\n" +
                "<a href=SYSTEM_URL style=\"color: #2c84ea; font-weight: bold;\"> system_url </a>\n" +
                "\n" +
                "<br>\n" +
                "\n" +
                " \n" +
                "\n" +
                "<p>Need help? Contact <strong> contact_no </strong> or send email to <strong>[ general_email ]</strong> for system enquiry.</p>\n" +
                "\n" +
                "<br>\n" +
                "\n" +
                "<p>Best regards,<br><strong>Airena Procure System</strong></p>\n" +
                "\n" +
                "\n" +
                "</div>");


        sb.append(top).append(h).append(l).append(m).append(g).append(p);
        return sb;
    }
}
